package cqrtplm.listener;

import cn.hutool.extra.spring.SpringUtil;
import com.hustcad.plm.pdm.workflow.annotion.CustomListener;
import com.hustcad.plm.pdm.workflow.annotion.CustomListenerField;
import cqrtplm.service.PointSelectionService;
import cqrtplm.service.RTUnlockProductOrderService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.flowable.engine.impl.el.FixedValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@CustomListener(category = "润通", description = "锁定或解锁成品订单")
public class RTUnlockProductOrderListener implements ExecutionListener {
    private static final Logger log = LoggerFactory.getLogger(RTUnlockProductOrderListener.class);
    @CustomListenerField(description = "锁单标识：1代表解锁，2代表锁定", defaultValue = "", required = true)
    private FixedValue isLock;
    @Override
    public void notify(DelegateExecution delegateExecution) {
        String workFlowContainerId = String.valueOf(delegateExecution.getVariable("workFlowContainerId"));
        RTUnlockProductOrderService unlockProductOrderService = SpringUtil.getBean(RTUnlockProductOrderService.class);
        if (isLock==null){
            log.info("RTUnlockProductOrderListener，，监听参数isLock为空,请给对应监听参数设置值！");
        }else {
            unlockProductOrderService.unlockProductOrder(workFlowContainerId, isLock.getExpressionText());
        }
    }
}
